package cn.springboottest.util;


import lombok.SneakyThrows;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class RedisMap {
    @SneakyThrows//
    public static <T> Map<String,String> toMap(T object){
        Map<String,String> res = new HashMap<>();
    Field[] fileds = object.getClass().getDeclaredFields();//得到变量名
        for(Field field:fileds){
            field.setAccessible(true);
            String key=field.getName();
            String value=field.get(object).toString();//
            res.put(key,value);
        }
        return res;
    }
}
